#!/usr/bin/python
# -*- coding: utf-8 -*-

class _Logger(object):
    def __init__(self):
        # Just for the information
        self.instance = "Instance at %d" % self.__hash__()
        self.logfile = None
        
    def setlogfile(self, file):
        if self.logfile:
            self.logfile.close()
        self.logfile = open(file, "w")
        
    def log(self, str):
        if self.logfile:
            self.logfile.write(str)
            self.logfile.flush()
        else:
            print str
        
        
_logger = _Logger()

def Logger(): return _logger